package com.nyist.myticket.web;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * *
 *
 * @author yangxiaogen
 * @date 2021/12/15 20:32
 */
public class ServletTestController extends HttpServlet {

    // 只会在项目启动的时候加载一次, 全局全生命周期使用, 重写的时候需要调用 父类的init方法
    @Override
    public void init() throws ServletException {
        super.init();
    }

    // 请求一次调用一次此方法, 根据相应的请求方式调用相应的方法, doGet 或者 doPost
    // 正在的业务逻辑处理的地方, 所以说 mvc 分层的时候业务逻辑写在 service 层呢? 我猜测
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.service(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }

    // 当项目停止或者销毁的时候调用一次, 销毁当前实例
    @Override
    public void destroy() {
        super.destroy();
    }
}
